package com.example.boot3.controller;

import com.example.boot3.model.Fleet;
import com.example.boot3.model.Vehicle;
import com.example.boot3.service.FleetService;
import com.example.boot3.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 邹成明
 * @date 2024/02/24
 */
@CrossOrigin(origins =  "*")
@RestController

@RequestMapping("/fleet")
public class FleetController {
    @Autowired
    private FleetService fleetService;
    @PostMapping("add")
    public JsonData addFleet(@RequestBody Fleet fleet) {
        Integer res=fleetService.addFleet(fleet.getFleet_name());
        if(res==1){
            return JsonData.buildSuccess(fleetService.addFleet(fleet.getFleet_name()));
        }
        else{
            return JsonData.buildError("车队名重复!");
        }

    }
}
